package by.msokoloff.javaweb2015.dataaccess;

import java.util.List;

import javax.persistence.metamodel.SingularAttribute;

public interface AbstractDao<Entity> {

	Entity getById(Integer id);

	Long getCount();

	List<Entity> getByField(SingularAttribute<? super Entity, ?> attr, Object val);

	Long getCountByField(SingularAttribute<? super Entity, ?> attr, Object val);

	List<Entity> getAll();

	List<Entity> getAll(SingularAttribute<? super Entity, ?> attr, boolean ascending, int startRecord, int pageSize);

	List<Entity> getAll(SingularAttribute<? super Entity, ?> filter, Object val, SingularAttribute<? super Entity, ?> attr, boolean ascending, int startRecord, int pageSize);

	List<Entity> getStartingWith(SingularAttribute<? super Entity, String> field, String val, Integer max);
	
	List<Entity> getContaining(SingularAttribute<? super Entity, String> field, String val, Integer max);
	
	Entity create(Entity entity);

	Entity update(Entity entity);

	void delete(Integer id);

	void delete(List<Integer> ids);

	void deleteAll();

}
